package com.gitee.vueantd.common.utils;

import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Auther:
 * @Date: 2020/7/29 15:34
 * @Description:
 */

public class DefaultThreadFactory implements ThreadFactory {
  private String prefix;

  private AtomicInteger counter = new AtomicInteger(1);

  public DefaultThreadFactory(String prefix) {
    this.prefix = prefix;
  }

  @Override
  public Thread newThread(Runnable r) {
    return new Thread(r, prefix + "-" + counter.getAndIncrement());
  }
}
